﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace N03_11HCA_HTTTHD.Controllers
{
    public class DoanhNghiepController : Controller
    {
        //
        // GET: /DoanhNghiep/

        Data_DAO_DTO_Lib.DOANHNGHIEP_DAO dnDAO = new Data_DAO_DTO_Lib.DOANHNGHIEP_DAO();
        //
        // GET: /ChaoBan/

        public ActionResult Index()
        {

            ViewBag.TK = N03_11HCA_HTTTHD.TienIch.HeThong.LayThongTinTKHienTai(Session);


            List<Data_DAO_DTO_Lib.DTO.DTO> list = dnDAO.LayDanhSachCoThamSo(0, TienIch.HeThong.SoLuongLoadDoanhNghiepMacDinh, TienIch.HeThong.ChuoiSapXepDoanhNghiepMacDinh);
            Models.DoanhNghiep model = new Models.DoanhNghiep(list);

            return View("DoanhNghiep", model);
        }

        [HttpPost]
        public JsonResult Index(int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
        {
            List<Data_DAO_DTO_Lib.DTO.DTO> list = dnDAO.LayDanhSachCoThamSo(jtStartIndex, jtPageSize, jtSorting);

            return new JsonResult() { Data = list };
        }

        public ActionResult ChiTiet(int id_TimMua)
        {
            ViewBag.TK = N03_11HCA_HTTTHD.TienIch.HeThong.LayThongTinTKHienTai(Session);


            Data_DAO_DTO_Lib.DTO.DOANHNGHIEP_DTO dnDTO = (Data_DAO_DTO_Lib.DTO.DOANHNGHIEP_DTO)dnDAO.LayTuID(id_TimMua);


            List<Data_DAO_DTO_Lib.DTO.DTO> lDanhMuc = new List<Data_DAO_DTO_Lib.DTO.DTO>();
            //add tĩnh
            Data_DAO_DTO_Lib.DTO.DANHMUC_DTO dm1 = new Data_DAO_DTO_Lib.DTO.DANHMUC_DTO();
            dm1.ID = 1;
            dm1.SoLuongTrongDanhMuc = 100;
            dm1.TenDanhMuc = "Danh mục 1";

            Data_DAO_DTO_Lib.DTO.DANHMUC_DTO dm2 = new Data_DAO_DTO_Lib.DTO.DANHMUC_DTO();
            dm2.ID = 2;
            dm2.SoLuongTrongDanhMuc = 100;
            dm2.TenDanhMuc = "Danh mục 2";

            lDanhMuc.Add(dm1);
            lDanhMuc.Add(dm2);

            Models.DoanhNghiep_ChiTiet model = new Models.DoanhNghiep_ChiTiet(dnDTO, lDanhMuc);

            return View("DoanhNghiep_ChiTiet", model);
        }
      
    }
}
